/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package sg.edu.nus.iss.pacman.form;

import javax.microedition.lcdui.TextBox;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.TextField;
import sg.edu.nus.iss.pacman.midlet.PacManMIDlet;

/**
 *
 * @author daniel
 */
public class UserProfileUploadMessage extends TextBox implements CommandListener{

    private static final String TITLE = "Upload User Profile";
	private static final String MESSAGE = "Do you want to upload your profile?";

	private PacManMIDlet mainApp;
    private Command cmdYes, cmdNo;
	
    public UserProfileUploadMessage(PacManMIDlet mainApp)
    {
        super(TITLE, MESSAGE, 100, TextField.ANY);
        this.mainApp = mainApp;

        init();
    }

    private void init()
    {
        cmdYes = new Command("Yes", Command.OK, 1);
        cmdNo = new Command("No", Command.EXIT, 1);

        addCommand(cmdYes);
        addCommand(cmdNo);
        setCommandListener(this);
    }

    public void commandAction(Command c, Displayable d)
    {
        if (cmdYes == c)
        {
            mainApp.uploadUserProfile();
        }
        else
        {
            mainApp.displayMainMenu();
        }
    }
}
